clear

/*

use "C:\Local\数据\ex2000/2001/2002/2003/2004 data.dta"

egen ownership = group(firmtype)

egen country = group(partner)

gen hs6 = substr(hs8, 1, 6)

g xx = trader

  bys hs6 country: egen totv = sum(value)
  bys hs6 country: egen totv_t = sum(value) if xx==1
  
collapse (mean) totv*, by(partner country hs6) fast
		
  foreach v of varlist totv* {
	replace `v' = 0 if `v' == .
			}
g s = totv_t/totv

label variable s "intermediary export share by country-hs6"

merge m:m partner using "C:\Local\数据\disance+population+GDP+document-2000/2001/2002/2003/2004.dta" 

drop _merge

merge m:m partner hs6 using "C:\Local\数据\hs6-mfn-2000/2001/2002/2003/2004.dta"

drop if _merge == 2

drop _merge

drop partner totv totv_t GDP distance population

save "C:\Local\数据\Table 6B\tabel 6 data - 2000/2001/2002/2003/2004.dta", replace

*/

/*

use "C:\Local\数据\Table 3\table 3 data.dta"

append using "C:\Local\数据\Table 6B\table 6 data - 2004.dta"

append using "C:\Local\数据\Table 6B\table 6 data - 2003.dta"

append using "C:\Local\数据\Table 6B\table 6 data - 2002.dta"

append using "C:\Local\数据\Table 6B\table 6 data - 2001.dta"

append using "C:\Local\数据\Table 6B\table 6 data - 2000.dta"

save "C:\Local\数据\Table 6B\table 6 data - panel.dta"

*/


/// Table 6B Panel A

use "C:\Local\数据\Table 6B\tabel 6 data - 2000/2001/2002/2003/2004.dta",clear

areg s lnDistance lnGDP lnpopulation tradeproc mfn, a(hs6) cluster(country)

areg s lnDistance lnGDP lnpopulation SurveyData mfn, a(hs6) cluster(country)

areg s lnDistance lnGDP lnpopulation document mfn, a(hs6) cluster(country)

/// Table 6B Panel B

use "C:\Local\数据\Table 6B\tabel 6 data - panel.dta",clear

xi: areg s lnDistance lnGDP lnpopulation tradeproc mfn i.year, a(hs6) cluster(country)

xi: areg s lnDistance lnGDP lnpopulation SurveyData mfn i.year, a(hs6) cluster(country)

xi: areg s lnDistance lnGDP lnpopulation document mfn i.year, a(hs6) cluster(country)

